home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn Microsoft Visual Basic 6.0 Now
/
Learn Microsoft Visual Basic 6.0 Now (Microsoft Press)(X03-58607)(1998).ISO
/
media
/
chap04
/
b04d005.cc2
< prev
next >
Wrap
Text File
|
1998-06-07
|
2KB
|
48 lines
0, In this demonstration you'll learn how
2, to use variables with the InputBox and
5, MsgBox functions. Variables are temporary
8, storage containers in a program and the
10, InputBox and MsgBox functions use
13, variables to hold critical values as they
16, work. The program I'll create is a simple
18, utility that prompts you for your name and
21, displays it on the form. First, I'll
24, create a label object on the form to
27, display the output. And I'll create a Command
32, button to prompt the user for input.
39, I'll set the Caption property of the
41, Command button to Input Box to identify the
44, dialog box that the function opens. Next,
53, I'll write the program code that
55, declares my variables and calls the InputBox
58, and MsgBox functions. The first line uses
67, the Dim keyword to declare two
69, variables, Prompt and FullName. Prompt will
73, contain the instructions for the InputBox
75, function, and FullName will hold the
78, user's name temporarily in the program. The
85, third line displays an input box and
87, assigns the information that comes back to
89, the FullName variable. The event
92, procedure then uses the MsgBox function to
95, display the user's name in a small dialog
97, box. The final program statement assigns
102, the FullName variable to the Caption
104, property of the Label1 object. When I close
108, the Code window and run the program,
112, Visual Basic displays my form in the
115, programming environment. When I click the
122, Command button, the InputBox function
125, displays a dialog box prompting me for my name.
128, I'll type my name and click the OK
133, button to finalize my input. The MsgBox
136, function displays it in a smaller dialog box
140, and when I click OK, it appears in the
143, label object on my form. All right, I
146, admit this has been a pretty simple
147, example, but hopefully it demonstrates the
150, powerful potential of variables and dialog
152, boxes in your programs. Together they
154, form the core of your
156, information-gathering capabilities.
158, END